package com.itcast.demo_one.kotlin

fun main(args: Array<String>) {
    /*var animal = Animal("小猫")
    animal.makeSound()*/

    var cat = Cat("小猫", 18, "白色")
    cat.makeSound()

    var dog = Dog(name = "小狗", age = 18, color = "黑色" )
    dog.makeSound()
}



// 1. 基础类
 open class Animal( var name:  String) {
   open fun makeSound() {
        println("$name 在发出声音")
    }
}

// 2. 继承类
class Cat( name: String, var age: Int, var color: String): Animal(name) {
    override fun makeSound() {
        super.makeSound()
        println("$name 在喵喵叫, 年龄: $age, 颜色: $color ")
    }
}

class Dog( name: String, var age: Int, var color: String): Animal(name) {
    override fun makeSound() {
        super.makeSound()
        println("$name 在汪汪叫, 年龄: $age, 颜色: $color ")
    }
}